package datos.gestores;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import datos.entidades.VehiculoElegido;

public class GestorDatosVehiculosElegidos implements GestorDatos {
	
	private int cantVehiculos;
	List <VehiculoElegido> vehiculosElegidos;

	public GestorDatosVehiculosElegidos() {
		vehiculosElegidos = new ArrayList <VehiculoElegido>();
		cantVehiculos = 0;
	}

	public boolean add (Object ve) {
		boolean exito;
		exito = this.vehiculosElegidos.add((VehiculoElegido)ve);
		if (exito == true)
			setCantVehiculos (getCantVehiculos()+1);
		
		return exito;
	}

	public Object get(int idx) {
		return ((VehiculoElegido) this.vehiculosElegidos.get(idx));
	}

	public int indexOf(Object vehiculoElegido) {
    	int idx;
    	
    	idx = vehiculosElegidos.indexOf((VehiculoElegido) vehiculoElegido);
    	
        return idx;
	}

	public void listar() {
        Iterator<VehiculoElegido> iter = vehiculosElegidos.iterator();
        
        while (iter.hasNext())
          System.out.println(iter.next());
	}

	public void loadData() throws IOException {}

	public void saveData() throws IOException {}
	
	public boolean remove(Object ve) {
    	boolean exito;
    	    	
		exito = this.vehiculosElegidos.remove(ve);
		if (exito == true)
			setCantVehiculos (getCantVehiculos()-1);
		
		return exito;
	}

	public void remove(int idx) {
		this.vehiculosElegidos.remove(idx);
		setCantVehiculos (getCantVehiculos()-1);
	}

	public void set(int idx, Object ve) {
		this.vehiculosElegidos.set(idx, (VehiculoElegido) ve);
	}
	
	public int getCantVehiculos () {
		return this.cantVehiculos;
	}
	
	public void setCantVehiculos (int cantVehiculosElegidos) {
		this.cantVehiculos = cantVehiculosElegidos;
	}
	 
}
